<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <form action="http://www.baidu.com">
        <input type="text" id="i1">
        <input type="submit" value="提交" onclick="return Submit()">
    </form>
    <script>
        function Submit() {
            var tag=document.getElementById('i1');
            if(tag.value.length>0){return true}
            else{alert('不能为空');return false}
        }
    </script>
</body>
</html>